package com.eling.elcms.travel.service.impl;

import com.eling.elcms.core.model.BaseModel;
import com.eling.elcms.privilege.model.User;
import com.eling.elcms.privilege.service.IUserManager;
import com.eling.elcms.travel.service.IApprovalRule;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class UserApprovalRule implements IApprovalRule {
	
	@Autowired
	IUserManager userManager;

	@Override
	public Map<String, String> candidatePara() {
		Map<String, String> map = new HashMap<>();
		User cond = new User();
		cond.setSeal(false);
		List<User> list = userManager.query(cond);
		for (User user : list) {
			map.put(user.getPkUser().toString(), user.getName());
		}
		return map;
	}

	@Override
	public User getApproval(String para, BaseModel model) {
		return userManager.get(Long.valueOf(para));
	}

}
